package RedBook;

import java.util.Scanner;

public class Main_0925_1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        int[] nums=new int[n+1];
        for (int i = 0; i < n; i++) {
            int num=cin.nextInt();
            nums[num]++;
        }
        for (int i = 1; i <=n ; i++) {
            if(nums[i]==0){
                System.out.println(i-1);
                return;
            }
        }
        System.out.println(0);
    }
}
